package com.ibeeking.found.common.config.feign;

import com.ibeeking.found.common.config.feign.fallback.TenantUserFallbackFactory;
import com.ibeeking.found.common.entity.LoginOpenUserDTO;
import com.ibeeking.found.common.entity.UserInfoDTO;
import com.ibeeking.nematos.constants.enums.LogConstant;
import com.ibeeking.nematos.utils.result.ResponseResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;

import java.util.List;

/**
 * @Author ibeeking
 */
@FeignClient(name = "base-upms-b-server", contextId = "tenantUserClient", path = "/b", fallbackFactory = TenantUserFallbackFactory.class, decode404 = true)
public interface TenantUserClient {

    /**
     * 根据用户id查询用户基本信息
     *
     * @param userId
     * @return
     */
    @PostMapping(value = "/user/feign/v1/queryLoginUser/{userId}")
    ResponseResult<UserInfoDTO> queryLoginUser(@PathVariable("userId") Long userId);

    /**
     * 根据appId查询开放用户信息
     *
     * @param appId
     * @return
     */
    @PostMapping(value = "/openuser/feign/v1/queryLoginUser/{appId}")
    ResponseResult<LoginOpenUserDTO> queryLoginUser(@PathVariable("appId") String appId);

    /**
     * 根据userId查询开放用户API权限
     *
     * @param userId
     * @return
     */
    @PostMapping(value = "/openuser/feign/v1/queryApis/{userId}")
    ResponseResult<List<String>> queryApis(@PathVariable("userId") Long currentId,
                                           @RequestHeader(value = LogConstant.TRACE_ID) String traceId,
                                           @RequestHeader(value = LogConstant.TENANT_ID) String tenantId,
                                           @RequestHeader(value = LogConstant.USER_ID) String userId,
                                           @RequestHeader(value = LogConstant.USER_NAME) String name,
                                           @RequestHeader(value = LogConstant.LOGIN_ROLE) String loginRole,
                                           @RequestHeader(value = LogConstant.LOGIN_SYSTEM) String loginSystem
    );

}
